package grib2db;

import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;
import java.util.Vector;

public class FileTree {
	public int length;

	public FileTree() {
		// length = getlength();
		// System.out.println(length);
	}

	public String[] grib2dir() {
		Properties pro = new Properties();
		try {
			pro.load(new FileInputStream("config/config.property"));
		} catch (FileNotFoundException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		// StringBuffer datapath_buf = new
		// StringBuffer().append(pro.getProperty("datapath"));
		String datapath = pro.getProperty("datapath");

		// String Filedir = sb3.toString();
		// String[] a = FileName.split(" ");

		Vector<String> VFileTree = new Vector<String>();
		int index = 0;
		File subfiledir = new File(datapath);
		String[] subdir = subfiledir.list();
		for (int i = 0; i < subdir.length; i++) {
			String dir = datapath + subdir[i];
			File filedir = new File(dir);
			String[] lastdir = filedir.list();
			for (int j = 0; j < lastdir.length; j++) {

				// /FileTree[index]= dir+"/"+lastdir[j];
				VFileTree.add(dir + "/" + lastdir[j]);
				// System.out.println(FileTree[index]);
				index++;
			}
		}
		String[] FileTree = new String[VFileTree.size()];
		for (int i = 0; i < VFileTree.size(); i++) {
			FileTree[i] = VFileTree.get(i);
		}
		return FileTree;
	}

	public static void main(String[] args) {
		FileTree a = new FileTree();
		String[] b = a.grib2dir();
		// a.grib2dir();
		for (int i = 0; i < b.length; i++) {
			System.out.println(b[i]);
		}
	}
}
